<fieldset class="ui-widget ui-widget-content section">
    <legend class="ui-widget-header ui-corner-all">Company details</legend>
    <table class="ui-widget-content" style="width:100%;">
        <tr>
            <th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('cname')); ?></th>
        <td><?php echo CHtml::encode($model->cname); ?></td>
        </tr>
        <tr>
        <th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('address')); ?></th>
        <td><?php echo CHtml::encode($model->address); ?></td>
        </tr>
        <tr>
        <th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('postal')); ?></th>
        <td><?php echo CHtml::encode($model->postal); ?></td>
        </tr>
        <tr>
        <th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('country_code')); ?></th>
        <td><?php echo CHtml::encode($model->country_code); ?></td>
        </tr>
        <tr>
        <th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('email')); ?></th>
        <td><?php echo CHtml::encode($model->email); ?></td>
        </tr>
        <tr>
        <th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('pic')); ?></th>
        <td><?php echo CHtml::encode($model->pic); ?></td>
        </tr>
    </table>
</fieldset>
<?php
$contacts = array();
    if(count($model->telephone())>0):
        foreach($model->telephone() as $contact) {
            $contacts[$contact['type']]['ref'] = (empty($contacts[$contact['type']]['ref']))?$contact['ref']:trim($contacts[$contact['type']]['ref']).', '.$contact['ref'];
        }
?>
<fieldset id="telephone" class="ui-widget ui-widget-content section">
    <legend class="ui-widget-header ui-corner-all">Company Telephone No.</legend>
    <table class="ui-widget-content" style="width:100%;">
        <?php foreach($contacts as $type=>$contact): ?>
        <tr>
            <th class="label ui-widget-header">
                <?php echo CHtml::encode(company::model()->teleType[$type]); ?>
            </th>
            <td>
                <?php echo CHtml::encode($contact['ref']); ?>
            </td>
        </tr>
        <?php endforeach; ?>
    </table>
</fieldset>
<?php endif; ?>
<?php
$contacts = array();
    if(count($model->fax())>0):
        foreach($model->fax() as $contact) {
            $contacts[$contact['type']]['ref'] = (empty($contacts[$contact['type']]['ref']))?$contact['ref']:trim($contacts[$contact['type']]['ref']).', '.$contact['ref'];
        }
?>
<fieldset id="fax" class="ui-widget ui-widget-content section">
    <legend class="ui-widget-header ui-corner-all">Company Fax No.</legend>
    <table class="ui-widget-content" style="width:100%;">
        <?php foreach($contacts as $type=>$contact): ?>
        <tr>
            <th class="label ui-widget-header">
                <?php echo CHtml::encode(company::model()->faxType[$type]); ?>
            </th>
            <td>
                <?php echo CHtml::encode($contact['ref']); ?>
            </td>
        </tr>
        <?php endforeach; ?>
    </table>
</fieldset>
<?php endif; ?>